# Maintainer: Antoine Martin <totaam@xpra.org>

_realname=lzo
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=1.12
pkgrel=1
pkgdesc="This package provides python bindings for the LZO compression library (mingw-w64)"
arch=('any')
url='https://github.com/jd-boyd/python-lzo'
license=('GPL2')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-lzo2")
#checkdepends=("${MINGW_PACKAGE_PREFIX}-python-nose")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/jd-boyd/python-lzo/archive/v${pkgver}.tar.gz")
sha512sums=('bf418a44e54d7a811f735623af2e05fd08b94ed6a04e4577b0a8dc10c44f06885c679f523595e914d5f4758ff5a77d734f05930e77fdfea318f4ea2c57890633')

prepare() {
  cd "${srcdir}"

  rm -rf python-build-${CARCH} | true
  cp -r "python-${_realname}-${pkgver}" "python-build-${CARCH}"
  sed -i -e 's+lzo2.lib+lib/liblzo2.a+g' "python-build-${CARCH}/setup.py"
}

build() {
  msg "Python build for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  LZO_DIR="${MINGW_PREFIX}" ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  LZO_DIR="${MINGW_PREFIX}" ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --skip-build

  install -Dm644 COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
